package com.twobyeyoung.nearby;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.twobyeyoung.R;
import com.twobyeyoung.common.ShowMapOrListBar;

public class NearListFragment extends Fragment {

	View view;
	ListView mListView;
	NearListAdapter mSearchListAdapter;
	ShowMapOrListBar mShowMapOrListBar;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.surround_list, container, false);
		mListView = (ListView) view.findViewById(R.id.surround_people);
		mSearchListAdapter = new NearListAdapter(getActivity());
		mListView.setAdapter(mSearchListAdapter);
		mShowMapOrListBar = (ShowMapOrListBar) view.findViewById(R.id.action_bar);
		mShowMapOrListBar.setCurrentMode(ShowMapOrListBar.LIST_MODE);
		mShowMapOrListBar.setOnClickListener(new BarListener());
		return view;
	}
	
	private class BarListener implements View.OnClickListener {

		@Override
		public void onClick(View v) {
			switch(v.getId()) {
			case R.id.bar_list:
				break;
			case R.id.bar_map:				
				startActivity(new Intent(getActivity(), NearMapActivity.class));
				getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
				break;
			case R.id.bar_filter:
				startActivity(new Intent(getActivity(), FilterActivity.class));
				break;
			}
		}
	}	
}
